<template>
    <el-select :value="value" :clearable="clearable" placeholder="请选择" @change="changeSelectedNodes">
        <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
    </el-select>
</template>

<script>

import {DICT_DATA} from './dict-data';

export default {
    name: 'DictSelect',
    model: {
        prop: 'value',
        event: 'change'
    },
    props: {
        dict: String,
        value: [String, Number],
        clearable: {
            type: Boolean,
            default: true
        }
    },
    data() {
        return {

        };
    },
    computed: {
        options() {
            if (this.dict) {
                return DICT_DATA[this.dict];
            } else {
                return [];
            }
        }
    },
    watch: {

    },
    mounted() {

    },
    methods: {
        changeSelectedNodes(selectedData) {
            this.$emit('change', selectedData);
        }
    }
};
</script>
